package cn.edu.csust.tysp.backend.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

/**
 * 文件上传器
 *
 * @Auther: comtom
 * @Date: 2019/3/18 17:20
 */
@Configuration
public class MultipartResolverConfig {

    @Bean(name = "multipartResolver")
    @Primary
    public MultipartResolver getMultipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        multipartResolver.setDefaultEncoding("UTF-8");
        multipartResolver.setResolveLazily(true);
        multipartResolver.setMaxUploadSize(524288000L);//500M
        multipartResolver.setMaxInMemorySize(52428800);//50M
        return multipartResolver;
    }

}
